<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      var name = "全局";

      function fun() {
        console.log(obj2.name);
      }
      // 创建两个对象
      var obj = {
        name: "孙悟空",
        sayName: fun,
      };
      var obj2 = {
        name: "沙和尚",
        sayName: fun,
      };
      // obj.sayName();
      obj2.sayName();
    </script>
  </head>
  <body></body>
</html>
